package oj;

/**
 * @author 郝文雪
 * @date 2022/8/10 17:14
 * @Description Test
 */
public class LC1545 {
    //简单的数学运算
    public char findKthBit(int n, int k) {
        if(n==1) return '0';
        int sum=count(n);
        int mid=sum+1;

        if(mid==k){
            return '1';
        }else if(mid>k){
            return findKthBit(n-1,k);
        }else{
            char c=findKthBit(n-1,2*mid-k);
            return c=='0'?'1':'0';
        }

    }
    private int count(int n){
        int f=1;
        for(int i=1;i<n;i++){
            f=2*f+1;
        }
        return f;
    }
}
